#if !defined(AFX_SELECTOBJECTDLG_H__E32A4E43_163A_4B9D_B0F2_2CFDE13FC989__INCLUDED_)
#define AFX_SELECTOBJECTDLG_H__E32A4E43_163A_4B9D_B0F2_2CFDE13FC989__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SelectObjectDlg.h : header file
//

#include "HyperGraph/IHyperGraph.h"

struct ITimer;
class CBaseObject;


/////////////////////////////////////////////////////////////////////////////
// CSelectObjectDlg dialog

class CSelectObjectDlg : public CXTResizeDialog, public IEditorNotifyListener, public IHyperGraphManagerListener
{
	DECLARE_DYNCREATE(CSelectObjectDlg)
	// Construction
public:
	static void CSelectObjectDlg::RegisterViewClass();
	static CSelectObjectDlg* GetInstance();

	typedef std::map<CString,int> TGeometryCountMap;
	typedef std::map<CBaseObjectPtr, CString> ObjToStrMap;
	typedef std::map<uint32,CString> TSpecMap;

	static const CString& GetFlowGraphNames( CBaseObject* pObject );
	static const CString& GetTrackViewName( CBaseObject* pObject );

	// This function makes sure all empty strings are displayed at the end after column sorting
	static int ComparedEmptyStringAsLast(const CString &cmpText1, const CString &cmpText2, int &cmp, int &order);
	
	static void GetExtraLightInfo(CBaseObject *pObject, CString &csText);

	void UpdateGeomCount();
	static bool GetGeomCount(CBaseObject *pObject, int &val);
	static bool GETLODNumber(CBaseObject *pObject, int &nLodNumber);

	// Dialog Data
	enum { IDD = IDD_SELECT_OBJECT };
	CListCtrl	m_list;
	static BOOL	m_bEntity;
	static BOOL	m_bPrefabs;
	static BOOL	m_bOther;
	static BOOL	m_bTagPoint;
	static BOOL	m_bAIPoint;
	static BOOL	m_bGroups;
	static BOOL	m_bVolumes;
	static BOOL	m_bShapes;
	static BOOL  m_bBrushes;
	static BOOL  m_bAutoselect;
	static BOOL  m_bTree;
	static BOOL  m_bSolids;
	static BOOL m_bSearchInsideObjects;
	CCustomButton m_hideBtn;
	CCustomButton m_freezeBtn;
	CCustomButton m_selAllBtn;
	CCustomButton m_selNoneBtn;
	CCustomButton m_selInvBtn;
	CCustomButton m_selByPropertyName;
	CCustomButton m_selByPropertyValue;
	CCustomButton m_refreshBtn;
	CCustomButton m_selectBtn;
	CCustomButton m_deleteBtn;
	CEdit m_propertyFilterCtrl;
	CStatic m_numObjects;
	CComboBox m_comboLastColumn;

	static int m_sortFlags;
	static TSpecMap m_specMap;
	static int m_nLastSelectedItemPosition;

	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSelectObjectDlg)
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

	// Implementation
protected:
	CSelectObjectDlg(CWnd* pParent = NULL);   // standard constructor
	void OnObjectEvent( CBaseObject *pObject,int event );
	void UpdateStatusText();
	void OnLayerUpdate( int event,CObjectLayer *pLayer );

	virtual void OnEditorNotifyEvent( EEditorNotifyEvent event );
	virtual void OnHyperGraphManagerEvent( EHyperGraphEvent event, IHyperGraph* pGraph, IHyperNode* pINode );

	// Generated message map functions
	//{{AFX_MSG(CSelectObjectDlg)
	virtual void OnOK();
	virtual void OnCancel();
	virtual void PostNcDestroy();

	afx_msg void OnSelAll();
	afx_msg void OnSelNone();
	afx_msg void OnSelInv();
	virtual BOOL OnInitDialog();
	afx_msg void OnDestroy();
	afx_msg void OnListType();
	afx_msg void OnRefresh();
	afx_msg void OnColumnclickObjects(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnUpdateFastfind();
	afx_msg void OnClickObjects(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnVisible();
	afx_msg void OnHidden();
	afx_msg void OnFrozen();
	afx_msg void OnHide();
	afx_msg void OnFreeze();
	afx_msg void OnDeleteSelected();
	afx_msg void OnMatchPropertyName();
	afx_msg void OnMatchPropertyValue();
	afx_msg void OnItemchangedObjects(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDblclkObjects(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSelectionChanged();
	afx_msg void OnSelTypesAll();
	afx_msg void OnSelTypesNone();
	afx_msg void OnSelTypesInvert();
	afx_msg void GetDispInfo(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTimer(UINT_PTR timerVal);

	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	bool AddObject( CBaseObject *obj,int level );
	void AddObjectRecursively( CBaseObject *obj,int level );
	void FillList(bool bRebuildMaps = false);
	void EnableControls();
	void SelectItemObject( int iItem );
	bool IsPropertyMatch( CBaseObject *pObject );
	bool IsPropertyMatchVariable( IVariable *pVar );

	void UpdateListTypes(int nState);

	UINT StartFilterTimer(UINT duration);

	static int m_displayMode;
	bool m_picking;
	bool m_bIgnoreObjectCallback;

	CString m_nameFilter;
	CString m_propertyFilter;
	bool m_bMatchPropertyName;
	bool m_bSelectionChanged;

	int m_listMask;

	CImageList m_imageList;

	struct IObjectManager* m_pObjMan;

	//! Single instance of this dialog.
	static CSelectObjectDlg* m_instance;

	//! Flag for LinkTool activated
	bool m_bIsLinkTool;

	bool m_bLayerModified;

	bool m_bTimerActivated;
	bool m_bTimerActivationRequest;

	//! Cached & sorted objects for the on-demand display of the list control
	std::vector<CBaseObject*> m_objects;
	std::vector<int> m_indentState;

	// For a faster retrieval of TrackView, FlowGraph ref info
	static ObjToStrMap s_flowGraphMap;
	static ObjToStrMap s_trackViewMap;
	bool m_bTrackViewModified;
	std::vector<GUID> m_modifiedFlowGraphObjects;

	static TGeometryCountMap m_mGeomCountMap;

	void AddObjectToMaps(CBaseObject* pObject);
	void UpdateFlowGraphInMaps(REFGUID guid);
	void BuildMaps();
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SELECTOBJECTDLG_H__E32A4E43_163A_4B9D_B0F2_2CFDE13FC989__INCLUDED_)
